package org.dtrd.modules.evaluation.entity.bean;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.dtrd.modules.evaluation.constant.Evaluation;
import org.dtrd.modules.evaluation.entity.po.DtrdEntEvaluationRdBmq;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
* @Author: QR
* @Date: 2021/9/26-17:14
*/

@EqualsAndHashCode(callSuper = true)
@ApiModel("BMQ量表数据")
@Data
public class BmqInfo extends BasicInfo{

    private Integer dataId;

    @ApiModelProperty("创建时间")
    private Date createTime;

    @ApiModelProperty("答案")
    private List<Integer> answers;

    @ApiModelProperty("总分")
    private Integer score;

    @ApiModelProperty("输出结果")
    private String output;

    public BmqInfo parseFromPo(DtrdEntEvaluationRdBmq po){
        this.setDataId(po.getDataId());
        this.setPatientId(po.getPatientId());
        this.setCreateTime(po.getCreateTime());
        this.setScore(po.getScore());
        this.setOutput(po.getOutput());
        String[] answerStrings = po.getInput().split(",");
        ArrayList<Integer> answers = new ArrayList<>(Evaluation.ProblemNum.BMQ.getNum());
        for (String s : answerStrings) {
            Integer answer = Integer.parseInt(s);
            answers.add(answer);
        }
        this.setAnswers(answers);
        return this;
    }
}
